/**
 * MelonPalette.java 2005. 6. 23.
 *
 * @copyrights 2004 PSIA Corp. All rights are reserved.
 */
package cs348a.color;

/**
 * A <code>MelonPalette</code> defines a yellow and green combination palette.
 *
 * @author Taeksoo Jung, YoungJin Kim
 */
public final class MelonPalette extends BasicPalette {
	/** Singleton instance */
	public static final MelonPalette INSTANCE = getInstance();
	
	/**
	 * Constructor for <code>MelonPalette</code>.
	 * 
	 * @param reds array of red components
	 * @param greens array of green components
	 * @param blues array of blue components
	 */
	private MelonPalette(byte[] reds, byte[] greens, byte[] blues) {
		super("Melon", reds, greens, blues);
	}
	
	/**
	 * Returns the singleton instance.
	 * 
	 * @return the singleton instance
	 */
	private static MelonPalette getInstance() {
		// Creates arrays of components.
		byte[] reds = new byte[SIZE];
		byte[] greens = new byte[SIZE];
		byte[] blues = new byte[SIZE];

		// Constructs the components.
		for (int i = 0; i < SIZE; i++) {
			// Sets the red component.
			double f = i * 2 - SIZE / 2.0;
			reds[i] = cutOff(f);
			
			// Sets the green component.
			f = i * 2 - SIZE * 0.15;
			greens[i] = cutOff(f);
			
			// Sets the blue component.
			f = i * 2 - SIZE * 0.9;
			blues[i] = cutOff(f);
		}

		return new MelonPalette(reds, greens, blues);
	}
}
